<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: CalendarDateSelect::FormHelpers</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">CalendarDateSelect::FormHelpers</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/plugins/calendar_date_select-1_15/lib/calendar_date_select/form_helpers_rb.html">
                vendor/plugins/calendar_date_select-1.15/lib/calendar_date_select/form_helpers.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Various helpers available for use in your view
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000012">calendar_date_select</a>&nbsp;&nbsp;
      <a href="#M000011">calendar_date_select_tag</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">calendar_date_select</span><span class="method-args">(object, method, options={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Similar to the difference between <tt>text_field_tag</tt> and
<tt>text_field</tt>, this method behaves like <tt>text_field</tt>
</p>
<p>
It receives the same options as <tt><a
href="FormHelpers.html#M000011">calendar_date_select_tag</a></tt>. Need for
time selection is automatically detected by checking the corresponding
column meta information of Model#columns_hash
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/calendar_date_select-1.15/lib/calendar_date_select/form_helpers.rb, line 115</span>
115:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calendar_date_select</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">method</span>, <span class="ruby-identifier">options</span>={})
116:     <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:object</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">&quot;@#{object}&quot;</span>)
117: 
118:     <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:time</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;columns_hash&quot;</span>)
119:       <span class="ruby-identifier">column_type</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">columns_hash</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>].<span class="ruby-identifier">type</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>)
120:       <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:time</span>] = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">column_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:datetime</span>
121:     <span class="ruby-keyword kw">end</span>
122: 
123:     <span class="ruby-identifier">use_time</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:time</span>]
124: 
125:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:time</span>].<span class="ruby-identifier">to_s</span><span class="ruby-operator">==</span><span class="ruby-value str">&quot;mixed&quot;</span>
126:       <span class="ruby-identifier">use_time</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Date</span><span class="ruby-operator">===</span>(<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">method</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>))
127:     <span class="ruby-keyword kw">end</span>
128: 
129:     <span class="ruby-identifier">image</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">javascript_options</span> = <span class="ruby-identifier">calendar_date_select_process_options</span>(<span class="ruby-identifier">options</span>)
130: 
131:     <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:value</span>] <span class="ruby-operator">||=</span>
132:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">method</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>).<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:strftime</span>))
133:         <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-constant">CalendarDateSelect</span>.<span class="ruby-identifier">date_format_string</span>(<span class="ruby-identifier">use_time</span>))
134:       <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;#{method}_before_type_cast&quot;</span>)
135:         <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{method}_before_type_cast&quot;</span>)
136:       <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">method</span>)
137:         <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>).<span class="ruby-identifier">to_s</span>
138:       <span class="ruby-keyword kw">else</span>
139:         <span class="ruby-keyword kw">nil</span>
140:       <span class="ruby-keyword kw">end</span>
141: 
142:     <span class="ruby-identifier">tag</span> = <span class="ruby-constant">ActionView</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceTag</span>.<span class="ruby-identifier">new_with_backwards_compatibility</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">method</span>, <span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:object</span>))
143:     <span class="ruby-identifier">calendar_date_select_output</span>(
144:       <span class="ruby-identifier">tag</span>.<span class="ruby-identifier">to_input_field_tag</span>( (<span class="ruby-identifier">javascript_options</span>[<span class="ruby-identifier">:hidden</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">javascript_options</span>[<span class="ruby-identifier">:embedded</span>]) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;hidden&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;text&quot;</span>, <span class="ruby-identifier">options</span>),
145:       <span class="ruby-identifier">image</span>,
146:       <span class="ruby-identifier">options</span>,
147:       <span class="ruby-identifier">javascript_options</span>
148:     )
149:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">calendar_date_select_tag</span><span class="method-args">( name, value = nil, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Similar to text_field_tag, but adds a calendar picker, naturally.
</p>
<h2>Arguments</h2>
<pre>
  +name+ - the html name of the tag
  +value+ - When specified as a string, uses value verbatim.  When Date, DateTime, Time, it converts it to a string basd off the format set by CalendarDateSelect#format=
  +options+ - ...
</pre>
<h2>Options</h2>
<h3>:embedded</h3>
<p>
Put the calendar straight into the form, rather than using a popup type of
form.
</p>
<pre>
  &lt;%= calendar_date_select_tag &quot;name&quot;, &quot;2007-01-01&quot;, :embedded =&gt; true %&gt;
</pre>
<h3>:hidden</h3>
<p>
Use a hidden element instead of a text box for a pop up calendar. Not
compatible with :embedded =&gt; true. You&#8216;ll probably want to use an
onchange callback to do something with the value.
</p>
<pre>
  &lt;span id='cds_value' /&gt;
  &lt;%= calendar_date_select_tag &quot;hidden_date_selector&quot;, &quot;&quot;, :hidden =&gt; &quot;true&quot;, :onchange =&gt; &quot;$('cds_value').update($F(this));&quot; %&gt;
</pre>
<h3>:image</h3>
<p>
Specify an alternative icon to use for the date picker.
</p>
<p>
To use /images/groovy.png:
</p>
<pre>
  &lt;%= calendar_date_select_tag &quot;altered_image&quot;, &quot;&quot;, :image =&gt; &quot;groovy.png&quot; %&gt;
</pre>
<h3>:minute_interval</h3>
<p>
Specifies the minute interval used in the hour/minute selector. Default is
5.
</p>
<pre>
  &lt;%= calendar_date_select_tag &quot;month_year_selector_label&quot;, &quot;&quot;, :minute_interval =&gt; 15 %&gt;
</pre>
<h3>:month_year</h3>
<p>
Customize the month and year selectors at the top of the control.
</p>
<p>
Valid values:
</p>
<pre>
 * &quot;dropdowns&quot; (default) - Use a separate dropdown control for both the month and year
 * &quot;label&quot; - Use static text to show the month and the year.

   &lt;%= calendar_date_select_tag &quot;month_year_selector_label&quot;, &quot;&quot;, :month_year =&gt; &quot;label&quot; %&gt;
</pre>
<h3>:popup =&gt; &#8216;force&#8216;</h3>
<p>
Forces the user to use the popup calendar by making it&#8216;s text-box
read-only and causing <a
href="FormHelpers.html#M000012">calendar_date_select</a> to override
it&#8216;s default behavior of not allowing selection of a date on a target
element that is read-only.
</p>
<pre>
  &lt;%= calendar_date_select_tag &quot;name&quot;, &quot;2007-01-01&quot;, :popup =&gt; &quot;force&quot; %&gt;
</pre>
<h3>:time</h3>
<p>
Show time in the controls. There&#8216;s three options:
</p>
<pre>
 * +true+ - show an hour/minute selector.
 * +false+ - don't show an hour/minute selector.
 * +&quot;mixed&quot;+ - Show an hour/minute selector, but include a &quot;all day&quot; option - allowing them to choose whether or not to specify a time.
</pre>
<h3>:year_range</h3>
<p>
Limit the year range. You can pass in an array or range of ruby Date/Time
objects or FixNum&#8216;s.
</p>
<pre>
  &lt;%= calendar_date_select_tag &quot;e_date&quot;, nil, :year_range =&gt; 10.years.ago..0.years.from_now %&gt;
  &lt;%= calendar_date_select_tag &quot;e_date&quot;, nil, :year_range =&gt; [0.years.ago, 10.years.from_now] %&gt;
  &lt;%= calendar_date_select_tag &quot;e_date&quot;, nil, :year_range =&gt; 2000..2007 %&gt;
  &lt;%= calendar_date_select_tag &quot;e_date&quot;, nil, :year_range =&gt; [2000, 2007] %&gt;
</pre>
<h2>CALLBACKS</h2>
<p>
The following callbacks are available:
</p>
<pre>
 * before_show / after_show
 * before_close / after_close
 * after_navigate - Called when navigating to a different month. Passes first parameter as a date object refering to the current month viewed
 * onchange - Called when the form input value changes

  &lt;%= calendar_date_select_tag &quot;event_demo&quot;, &quot;&quot;,
    :before_show =&gt; &quot;log('Calendar Showing');&quot; ,
    :after_show =&gt; &quot;log('Calendar Shown');&quot; ,
    :before_close =&gt; &quot;log('Calendar closing');&quot; ,
    :after_close =&gt; &quot;log('Calendar closed');&quot;,
    :after_navigate =&gt; &quot;log('Current month is ' + (param.getMonth()+1) + '/' + (param.getFullYear()));&quot;,
    :onchange =&gt; &quot;log('value changed to - ' + $F(this));&quot;
</pre>
<p>
}}}
</p>
<p>
All callbacks are executed within the context of the target input element.
If you&#8216;d like to access the <a
href="../CalendarDateSelect.html">CalendarDateSelect</a> object itself, you
can access it via &quot;this.calendar_date_select&quot;.
</p>
<p>
For example:
</p>
<pre>
  &lt;%= calendar_date_select_tag &quot;event_demo&quot;, &quot;&quot;, :after_navigate =&gt; &quot;alert('The current selected month is ' + this.calendar_date_select.selected_date.getMonth());&quot; ,
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/calendar_date_select-1.15/lib/calendar_date_select/form_helpers.rb, line 98</span>
 98:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calendar_date_select_tag</span>( <span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span> = {})
 99:     <span class="ruby-identifier">image</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">javascript_options</span> = <span class="ruby-identifier">calendar_date_select_process_options</span>(<span class="ruby-identifier">options</span>)
100:     <span class="ruby-identifier">value</span> = <span class="ruby-constant">CalendarDateSelect</span>.<span class="ruby-identifier">format_time</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">javascript_options</span>)
101: 
102:     <span class="ruby-identifier">javascript_options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:format</span>)
103: 
104:     <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:id</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">name</span>
105:     <span class="ruby-identifier">tag</span> = <span class="ruby-identifier">javascript_options</span>[<span class="ruby-identifier">:hidden</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">javascript_options</span>[<span class="ruby-identifier">:embedded</span>] <span class="ruby-operator">?</span>
106:       <span class="ruby-identifier">hidden_field_tag</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span>) <span class="ruby-operator">:</span>
107:       <span class="ruby-identifier">text_field_tag</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span>)
108: 
109:     <span class="ruby-identifier">calendar_date_select_output</span>(<span class="ruby-identifier">tag</span>, <span class="ruby-identifier">image</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">javascript_options</span>)
110:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>